home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / djgpp / libsrc / c / dos / int86x.s < prev    next >
Encoding:
Text File  |  1993-12-15  |  1.3 KB  |  104 lines

  1.     .data
  2. ds:
  3.     .word    0
  4. es:
  5.     .word    0
  6. fs:
  7.     .word    0
  8. gs:
  9.     .word    0
  10.  
  11.     .globl    int86
  12. int86:
  13.     .byte    0x2e
  14.     push    ds
  15.     pop    %ds
  16.     .byte    0x2e
  17.     push    es
  18.     pop    %es
  19.     .byte    0x2e
  20.     push    fs
  21.     pop    %fs
  22.     .byte    0x2e
  23.     push    gs
  24.     pop    %gs
  25.  
  26.     .byte    0xcd
  27. int86_vec:
  28.     .byte    0x03
  29.     ret
  30.  
  31.     .text
  32.     .globl    _int86x
  33. _int86x:
  34.     movl    16(%esp), %eax
  35.  
  36.     movw    2(%eax), %cx
  37.     movw    %cx, ds
  38.     movw    4(%eax), %cx
  39.     movw    %cx, es
  40.     movw    6(%eax), %cx
  41.     movw    %cx, fs
  42.     movw    8(%eax), %cx
  43.     movw    %cx, gs
  44.  
  45.     jmp    int86_common
  46.  
  47.     .globl    _int86
  48. _int86:
  49.     movw    %ds, %ax
  50.     movw    %ax, ds
  51.     movw    %ax, es
  52.     movw    %ax, fs
  53.     movw    %ax, gs
  54.     jmp    int86_common
  55.  
  56. int86_common:
  57.     pushl    %ebp
  58.     movl    %esp,%ebp
  59.     pushl    %ebx
  60.     pushl    %esi
  61.     pushl    %edi
  62.     pushf
  63.  
  64.     movl    8(%ebp),%eax
  65.     movb    %al,int86_vec
  66.  
  67.     movl    12(%ebp),%eax
  68.     movl    4(%eax),%ebx
  69.     movl    8(%eax),%ecx
  70.     movl    12(%eax),%edx
  71.     movl    16(%eax),%esi
  72.     movl    20(%eax),%edi
  73.     movl    (%eax),%eax
  74.  
  75.     push    %ds
  76.     push    %es
  77.     call    int86
  78.     pop    %es
  79.     pop    %ds
  80.  
  81.     pushf
  82.     pushl    %eax
  83.     movl    %esp,%ebp
  84.     addl    $24,%ebp
  85.     movl    16(%ebp),%eax
  86.     popl    (%eax)
  87.     movl    %ebx,4(%eax)
  88.     movl    %ecx,8(%eax)
  89.     movl    %edx,12(%eax)
  90.     movl    %esi,16(%eax)
  91.     movl    %edi,20(%eax)
  92.     popl    %ebx    /* flags */
  93.     movl    %ebx,28(%eax)
  94.     andl    $1,%ebx
  95.     movl    %ebx,24(%eax)
  96.     movl    (%eax),%eax
  97.  
  98.     popf
  99.     popl    %edi
  100.     popl    %esi
  101.     popl    %ebx
  102.     popl    %ebp
  103.     ret
  104.